package cn.iotab.iotkit.transport.mqtt.topic;

import lombok.Builder;
import lombok.Data;

@Data
@Builder
public class TopicMeta {

    private String topic;

    private MqttTopics.TopicType topicType;

    private String productKey;

    private String deviceId;

    public boolean isValid(){
        return topicType != MqttTopics.TopicType.UNKNOWN;
    }

    public static TopicMeta invalidTopic(String topic){
        return TopicMeta.builder().topic(topic).topicType(MqttTopics.TopicType.UNKNOWN).build();
    }

    public static TopicMeta validTopic(String topic, MqttTopics.TopicType topicType, String productKey, String deviceId){
        return TopicMeta.builder().topic(topic)
                .topicType(topicType).productKey(productKey).deviceId(deviceId).build();
    }
}
